package com.hdu.dwh.dao;

import com.hdu.dwh.properties.FlinkProperties;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
@Data
public class PaimonTableDao {
    private final FlinkTableDao flinkTableDao;
    private final FlinkProperties flinkProperties;

    /**
     * 复制表
     * @param sourceCatalog
     * @param sourceDatabase
     * @param sinkDatabase
     * @param sourceTable
     * @param sinkTable
     * @return
     */
    public boolean copyTable(String sourceCatalog, String sourceDatabase,String sinkDatabase, String sourceTable, String sinkTable) {
        return flinkTableDao.copyTable(sourceCatalog, flinkProperties.getCatalog(), sourceDatabase, sinkDatabase, sourceTable, sinkTable);
    }

    /**
     * 复制所有表
     * @param sourceCatalog
     * @param sourceDatabase
     * @param sinkDatabase
     * @return
     */
    public boolean copyAllTable(String sourceCatalog, String sourceDatabase, String sinkDatabase) {
        return flinkTableDao.copyAllTable(sourceCatalog, flinkProperties.getCatalog(), sourceDatabase, sinkDatabase);
    }


    /**
     * 删除表
     * @param database
     * @param table
     * @return
     */
    public boolean deleteTable(String database, String table) {
        return flinkTableDao.deleteTable(flinkProperties.getCatalog(), database, table);
    }


}
